﻿using NUnit.Framework;
using System.Collections.Generic;
using OpenSda.Agilcont.Common.Data.Contracts;
using OpenSda.Agilcont.Common.Data.Entities;
using System;


namespace OpenSda.Agilcont.Common.Data.NhContexts.NuTest
{
    [TestFixture]
    public class CorrelativoDocumentoDataTest : AbstractBaseDataTests
    {
        private ICorrelativoDocumentoData target;
        private IAgenciaData agenciaData;

        // These properties will be injected based on type
        public ICorrelativoDocumentoData CorrelativoDocumentoData { set { target = value; } }
        public IAgenciaData AgenciaData { set { agenciaData = value; } }


        [Test]
        public void SaveTest()
        {
            CorrelativoDocumento documentoCorrelativo = this.Save();
            Assert.IsNotNull(documentoCorrelativo.Identity);
        }

        private CorrelativoDocumento Save()
        {
            Agencia a = agenciaData.GetAll()[0];

            return target.Save(new CorrelativoDocumento()
            {
                Numero = 232,
                Serie = "eth56",
                DocumentoTipo = Entities.DocumentoTipo.BoletaVenta,
                AgenciaRef = a
                
            });
        }

        [Test]
        public void CorrelativoDocumentoDaoSeclectTests()
        {
            CorrelativoDocumento cd = target.Select(new Guid(""));
            Assert.IsNotNull(cd.Identity);
        }

        [Test]
        public void CorrelativoDocumentoDaListAllTests()
        {
            var cd = target.GetAll();

            Assert.IsTrue(cd.Count > 0);
        }

        [Test]
        public void CorrelativoDocumentoDeleteTests()
        {
            CorrelativoDocumento cd = this.Save();
            target.Delete(cd);
            CorrelativoDocumento cd2 = target.Select(cd.Identity);
            Assert.IsNull(cd2);
        }

    }
}
